<template>
  <el-button
    class="btnClass"
    type="primary"
    v-if="projectInfo.stageStatus === '5'"
    @click="handleNext"
    >下一步</el-button
  >
  <div>
    <h3>变更</h3>
    <!-- <el-form
      :model="formData"
      ref="formRef"
          @submit.prevent
      :rules="formRules"
      label-width="100px"
      @submit.prevent
    >
      <el-row>
        <el-col :xl="8" :lg="12">
          <el-form-item label="项目负责人" prop="name1">
            <el-input
              v-model.trim="formData.name1"
              class="width-custom"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :xl="8" :lg="12">
          <el-form-item label="项目成员" prop="name2">
            <el-input
              placeholder="请输入内容"
              v-model="formData.name2"
              class="width-custom"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :xl="8" :lg="12">
          <el-form-item label="评审专家" prop="name3">
            <el-input
              placeholder="请输入内容"
              v-model="formData.name3"
              class="width-custom"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form> -->
  </div>
</template>

<script lang="ts" setup>
// import { ref, reactive, unref } from "vue";
import { unref } from "vue";
import { postProjectUpdate } from "/@/api/project";
import { useRoute, useRouter } from "vue-router";

defineProps({
  projectInfo: {
    type: Object
  }
});

const route = useRoute();
const router = useRouter();

// let formData = reactive({
//   name1: "",
//   name2: "",
//   name3: ""
// });

// const formRules = ref({
//   name1: [{ required: true, message: "请输入名称", trigger: "change" }]
// });

const handleNext = async () => {
  try {
    const queryId = route.query?.id ?? "";

    const copyFormData = {
      id: queryId,
      clickStage: 5
    };

    const { code } = await postProjectUpdate(copyFormData);
    if (code === 200) {
      const { fullPath, query } = unref(route);
      router.replace({
        path: "/redirect" + fullPath,
        query: query
      });
    }
  } catch (err) {
    console.log(err);
  }
};
</script>

<style lang="scss" scoped>
.btnClass {
  margin-bottom: 8px;
}
</style>
